##############################################################################
# CMCC Service Guide Parser Makefile
# Copyright (c) 2008 Borqs
# All rights reserved

# Author Song.Bi
# Modify:
#	08-01-14 Initial 
#	08-01-17 Optimize
##############################################################################
CURRENT?=$(shell pwd)
export CURRENT

####### Compiler, tools and options

CC	=	gcc
CXX	=	g++
CFLAGS	=	-pipe -Wall -g -std=c89
CXXFLAGS=	-pipe -Wall -g

DEFINES	=	-DHAS_STDINT_H
DEFINES +=	-DHAVE_EXPAT_CONFIG_H
DEFINES	+=	-DDEBUG
DEFINES	+=	-UMEMORY_CONTROL
DEFINES	+=	-DEXTERN=
DEFINES	+=	-UTEST_INI
DEFINES	+=	-UTEST_FILE -DSGDD_RES_READ_SIZE=100*1024 -DSERVICE_GUIDE_XML_READ_SIZE=100*1024 -DSERVICE_GUIDE_XML_WRITE_SIZE=100*1024
DEFINES	+=	-UTEST_DB -UUSE_ALTERABLE_VARIABLES_DB
DEFINES	+=	-UTEST_XML_SCHEMA -DUSE_ALTERABLE_VARIABLES_SCHEMA
DEFINES	+=	-UTEST_XML_SCHEMA_DB -DUSE_SCHEMA_DB_SETTING_EXPENSION
DEFINES	+=	-UTEST_XML_SCHEMA_PARSER
DEFINES	+=	-UTEST_XML_SCHEMA_TRANSLATOR -DSUPPORT_NAMESPACE

DEFINES	+=	-DMAX_FILE_PATH_SIZE=256
DEFINES	+=	-DFILE_BUFFER_SIZE=1024

DEFINES	+=	-UTEST_HTTP
DEFINES	+=	-UTEST_SOCKET -DSOCKET_ENV_MUTEX_USED -USOCKET_ENV_USED
DEFINES	+=	-DBIND_TO_DEVICE
DEFINES	+=	-UTEST_TASK
DEFINES	+=	-UTEST_ENGINE -UTASK_SET_PARAM_OF_TYPE_FROM_EXTERNAL -DTASK_UNFOLD_EXTERNAL_HANDLE

DEFINES	+=	-DHTTP_RECV_BUF_SIZE=1024
DEFINES	+=	-DNETWORK_CONNECT_RETRY_MAX_TIMES=10
DEFINES	+=	-DNETWORK_CONNECT_TIMEOUT=1000000
DEFINES	+=	-DNETWORK_RECV_RETRY_MAX_TIMES=10
DEFINES	+=	-DNETWROK_SEND_TIMEOUT=1000000
DEFINES	+=	-DNETWROK_RECV_TIMEOUT=1000000
DEFINES	+=	-DHTTP_DEFAULT_USER_AGENT='"Mobile TV Client"'

DEFINES	+=	-DMBBMS_PATH=\"/sdcard/Documents/sdcard/\"
DEFINES	+=	-DMBBMS_FILE=\"/sdcard/Documents/sdcard/MBBMS_TEMP.dat\"
DEFINES	+=	-DMBBMS_TEL_FAKE_TRUE
DEFINES	+=	-DTAPI_CLIENT_FAKE_TRUE
DEFINES	+=	-DMBBMS_TEL_CLIENT_FAKE_TRUE
DEFINES	+=	-DTAPI_Dbg=printf\(\"\\n\"\)\;printf -DTAPI_Err=printf\(\"\\n\"\)\;printf

DEFINES	+=	-DMBBMS_ENV_FILENAME=\"mbbms/data/mbbms.ini\"

DEFINES	+=	-DTEST_MBBMS_PROCEDURE
DEFINES	+=	-UTEST_MBBMS_ENV

INCPATH	=	-I.	\
			-Idb/	\
			-Inet/	\
			-Isys/	\
			-Iutils/	\
			-Iutils/file/	\
			-Ixml/	\
			-Ixml/parser/	\
			-Ixml/schema/	\
			-Imbbms/	\
			-Imbbms/auth/	\
			-Imbbms/tel/	\
			-Imbbms/sg/	\
			-Imbbms/gba/	\
			-Imbbms/sub/	\
			-Imbbms/msk/	\
			-Imbbms/ri/	\
			-Imbbms/include/	\
			-Imbbms/manage/	\
			-Imbbms/proc/	\
			-Itask/	\
			-Iauth/	\
			-Itel/ \
			-Itel/impl/ \
			-Itel/tapi/ \
			-Itel/user_auth/ \
			-Itel/user_auth/mmc/ \
			-Itel/user_auth/comm/ \

LINK	=	gcc
LIBS	=	-lz -lpthread -lexpat -lm -lstdc++

####### Files

HEADERS	=	$(shell find . -name *.h) 
C__SRCS	=	$(shell find . -name *.c)
C__OBJS =	$(patsubst %.c,%.o,$(C__SRCS))
CPPSRCS	=	$(shell find . -name *.cpp)
CPPOBJS =	$(patsubst %.cpp,%.o,$(CPPSRCS))

TARGET	=	test

####### Implicit rules

.SUFFIXES: .cpp .c

.cpp.o: $(HEADERS)
	$(CXX) -c $(CXXFLAGS) $(DEFINES) $(INCPATH) -o $@ $<

.c.o: $(HEADERS)
	$(CC) -c $(CFLAGS) $(DEFINES) $(INCPATH) -o $@ $<

####### Build rules

all: $(TARGET)

$(TARGET): $(CPPOBJS) $(C__OBJS)
	$(LINK) $(LFLAGS) -o $(TARGET) $(CPPOBJS) $(C__OBJS) $(LIBS)

clean:
	-rm -f $(CPPOBJS) $(C__OBJS) $(TARGET)
	-rm -f *~ core



